<template>
	<view class="contain">
		<view class="conbox">
			<view class="img">
				<image class="rotate-center" src="@/static/rx.jpeg" style="width: 300rpx;border-radius: 50%;" mode="widthFix"></image>
			</view>
		</view>
		<view class="" style="margin-top: 100rpx;">
			<uni-forms :modelValue="formData">
						<uni-forms-item label="账号" name="name">
							<uni-easyinput type="text" v-model="formData.username" placeholder="请输入姓名" />
						</uni-forms-item>
						<uni-forms-item label="密码" name="password">
							<uni-easyinput type="text" v-model="formData.password" placeholder="请输入密码" />
						</uni-forms-item>
						<view class="" @click="tiao" style="text-align: right;font-size: 32rpx;">注册>></view>
						
			</uni-forms>
			<button type="primary" @click="login">登录</button>
		</view>
	</view>
</template>

<script>
	import {request} from '@/utils/request.js'
	export default {
		data() {
			return {
				formData:{
					username:"raoxing123",
					password:"123456"
				}
			}
		},
		onLoad() {
			
		},
		methods: {
			tiao(){
				uni.navigateTo({
					url:"/pages/regin/regin"
				})
			},
		async login(){
				const res=await request({url:"prod-api/api/login",method:'post',data:this.formData})
				console.log(res)
				uni.setStorage({
					key:'token',
					data:res.data.token
				})
				uni.showToast({
					icon:'success',
					title:"登录成功",
					success() {
						uni.switchTab({
							url:'/pages/index/index'
						})
					}
				})
			},
			// 发出登录请求
			
		}
	}
</script>

<style>
	.rotate-center {
		-webkit-animation: rotate-center 1s ease-in-out both;
		        animation: rotate-center 1s ease-in-out both;
	}
	.img{
		margin-top: 30rpx;
		text-align: center;
	}
/* ----------------------------------------------
 * Generated by Animista on 2023-10-18 13:31:12
 * Licensed under FreeBSD License.
 * See http://animista.net/license for more info. 
 * w: http://animista.net, t: @cssanimista
 * ---------------------------------------------- */

/**
 * ----------------------------------------
 * animation rotate-center
 * ----------------------------------------
 */
@-webkit-keyframes rotate-center {
  0% {
    -webkit-transform: rotate(0);
            transform: rotate(0);
  }
  100% {
    -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
  }
}
@keyframes rotate-center {
  0% {
    -webkit-transform: rotate(0);
            transform: rotate(0);
  }
  100% {
    -webkit-transform: rotate(360deg);
            transform: rotate(360deg);
  }
}

</style>
